package com.pkx.guide.common.util;


import com.pkx.guide.common.enums.ProtocolEnum;

/**
 * @author
 * @time 2022/6/30 10:27
 */
public class VmsUtils {
    // 字体转换，[in]=字体名，[return]=字体编码
    public static String fontCvt(ProtocolEnum protocol, String font) {
        String fontCode = "30";
        if(StringUtils.isEmpty(font)) return fontCode;
        if(protocol == ProtocolEnum.SWARCO_CMS_V1d5) {
            switch (font) { //+0x30
                case "黑体": fontCode = "30"; break;
                case "楷体": fontCode = "31"; break;
                case "宋体": fontCode = "32"; break;
                case "仿宋体": fontCode = "33"; break;
            }
        }
        return fontCode;
    }

    // 字体转换，[in]=字体编码，[return]=字体名
    public static String fontCodeCvt(ProtocolEnum protocol, String fontCode) {
        String font = "黑体";
        if(StringUtils.isEmpty(fontCode)) return font;
        if(protocol == ProtocolEnum.SWARCO_CMS_V1d5) {
            switch (fontCode) { //
                case "30": font = "黑体"; break;
                case "31": font = "楷体"; break;
                case "32": font = "宋体"; break;
                case "33": font = "仿宋体"; break;
            }
        }
        return font;
    }

    // 字体大小转换，[in]=字体大小，[return]=字体大小编码
    public static String fontSizeCvt(ProtocolEnum protocol, Integer fontSize) {
        String fontSizeCode = "33";
        if(fontSize == null) return fontSizeCode;
        if(protocol == ProtocolEnum.SWARCO_CMS_V1d5) {
            switch (fontSize) { //+0x30
//                case 16: fontSizeCode = "31"; break;
                case 24: fontSizeCode = "32"; break;
                case 32: fontSizeCode = "33"; break;
                case 48: fontSizeCode = "34"; break;
            }
        }
        return fontSizeCode;
    }

    // 字体大小转换，[in]=字体大小编码，[return]=字体大小
    public static Integer fontSizeCodeCvt(ProtocolEnum protocol, String fontSizeCode) {
        Integer fontSize = 24;
        if(StringUtils.isEmpty(fontSizeCode)) return fontSize;
        if(protocol == ProtocolEnum.SWARCO_CMS_V1d5) {
            switch (fontSizeCode) {
//                case "31": fontSize = 16; break;
                case "32": fontSize = 24; break;
                case "33": fontSize = 32; break;
                case "34": fontSize = 48; break;
            }
        }
        return fontSize;
    }

    // 字体颜色转换，[in]=字体颜色，[return]=字体颜色编码
    public static String fontColorCvt(ProtocolEnum protocol, String fontColor) {
        String fontColorCode = "21";
        if(StringUtils.isEmpty(fontColor)) return fontColorCode;
        if(protocol == ProtocolEnum.SWARCO_CMS_V1d5) {
            switch (fontColor) {
                case "红": fontColorCode = "20"; break;
                case "绿": fontColorCode = "21"; break;
                case "黄": fontColorCode = "22"; break;
            }
        }
        return fontColorCode;
    }

    // 字体颜色转换，[in]=字体颜色编码，[return]=字体颜色
    public static String fontColorCodeCvt(ProtocolEnum protocol, String fontColorCode) {
        String fontColor = "绿";
        if(StringUtils.isEmpty(fontColorCode)) return fontColor;
        if(protocol == ProtocolEnum.SWARCO_CMS_V1d5) {
            switch (fontColorCode) {
                case "20": fontColor = "红"; break;
                case "21": fontColor = "绿"; break;
                case "22": fontColor = "黄"; break;
            }
        }
        return fontColor;
    }

    // 图片转换，[in]=图片名，[return]=图片编码
    public static String picCvt(ProtocolEnum protocol, String picId) {
        String picCode = "53"; //限速60
        if(StringUtils.isEmpty(picId)) return picCode;
        if(protocol == ProtocolEnum.SWARCO_CMS_V1d5) {
            switch (picId) { //+0x30
                case "0": picCode = "30"; break; //无图片
                case "D7": picCode = "67"; break; //20
                case "D8": picCode = "68"; break; //25
                case "D9": picCode = "69"; break; //30
                case "C1": picCode = "51"; break; //35
                case "C2": picCode = "52"; break; //40
                case "DA": picCode = "6A"; break; //45
                case "DB": picCode = "6B"; break; //50
                case "DC": picCode = "6C"; break; //55
                case "C3": picCode = "53"; break; //60
                case "DD": picCode = "6D"; break; //65
                case "DE": picCode = "6E"; break; //70
                case "C4": picCode = "54"; break; //80
                case "DF": picCode = "6F"; break; //90
                case "C5": picCode = "55"; break; //100
                case "E0": picCode = "70"; break; //110
                case "C6": picCode = "56"; break; //120
                default: break;
            }
        }
        return picCode;
    }

    // 图片转换，[in]=图片编码，[return]=图片文件名
    public static String picCodeCvt(ProtocolEnum protocol, String picCode) {
        String picId = "C3"; //限速60
        if(StringUtils.isEmpty(picCode)) return picId;
        if(protocol == ProtocolEnum.SWARCO_CMS_V1d5) {
            switch (picCode) {
                case "30": picId = "0"; break; //无图片
                case "67": picId = "D7"; break; //20
                case "68": picId = "D8"; break; //25
                case "69": picId = "D9"; break; //30
                case "51": picId = "C1"; break; //35
                case "52": picId = "C2"; break; //40
                case "6A": picId = "DA"; break; //45
                case "6B": picId = "DB"; break; //50
                case "6C": picId = "DC"; break; //55
                case "53": picId = "C3"; break; //60
                case "6D": picId = "DD"; break; //65
                case "6E": picId = "DE"; break; //70
                case "54": picId = "C4"; break; //80
                case "6F": picId = "DF"; break; //90
                case "55": picId = "C5"; break; //100
                case "70": picId = "E0"; break; //110
                case "56": picId = "C6"; break; //120
                default: break;
            }
        }
        return picId;
    }
}
